import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	Scanner in;

	PrintWriter out;

	void solve() {
		int n = in.nextInt();
		int outOfPlace = 0;
		int place[] = new int[n];
		boolean used[] = new boolean[n];
		Arrays.fill(used, false);
		for (int i = 0; i < n; i++) {
			int pos = in.nextInt() - 1;
			if (pos != i) {
				outOfPlace++;
			}
			place[i] = pos;
		}
		int nChains = 0;
		for (int i = 0; i < used.length; i++) {
			if (!used[i]) {
				int next = i;
				while (true) {
					used[next] = true;
					next = place[next];
					if (used[next]) {
						break;
					}
				}
				nChains++;
			}
		}
		out.println(outOfPlace + (nChains - (n - outOfPlace)));
	}

	void run() {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		try {
			solve();
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

}
